<?php
declare(strict_types=1);
namespace app\tjy_v1\util\key;
// Aes处理
class Aes
{
    public static function index()
    {
        return '这是一个:AES加密解密算法处理类';
    }
    // 加密 
    public static function aesEncrypt(string $keyStr, string $plaintext): string
    {
        return base64_encode(openssl_encrypt($plaintext, 'AES-128-ECB', base64_decode($keyStr), OPENSSL_RAW_DATA));
    }
    // 解密
    public static function aesDecrypt(string $keyStr, string $ciphertext): string
    {
        return openssl_decrypt(base64_decode($ciphertext), 'AES-128-ECB', base64_decode($keyStr), OPENSSL_RAW_DATA);
    }
}
